package com.jwdf.uda.ui.adapter.viewholder;

import android.databinding.DataBindingUtil;
import android.text.TextUtils;
import android.view.View;
import com.jwdf.uda.R;
import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.databinding.ItemGuideDesignerShowBinding;
import com.jwdf.uda.ui.adapter.AbsViewHolder;
import com.jwdf.uda.ui.adapter.item.GuideDetailItem;
import com.jwdf.uda.utils.StringUtils;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * 类说明：
 */
public class GuideDesignerShowViewHolder extends AbsViewHolder<GuideDetailItem> {
    private ItemGuideDesignerShowBinding mItemBinding;

    public GuideDesignerShowViewHolder(View convertView) {
        super(convertView);
        mItemBinding = DataBindingUtil.bind(convertView);
    }

    @Override
    protected void onBindView(GuideDetailItem item) {
        final PbBean.PbUserSimple designerInfo = item.designerInfo;
        if (designerInfo == null) return;
        ImageLoader.getInstance().displayImage(designerInfo.getAvatar().getUrl(), mItemBinding.ivHeader);
        mItemBinding.tvNickName.setText(designerInfo.getNickname());
        mItemBinding.tvIntroduction.setVisibility(TextUtils.isEmpty(StringUtils.filterNullAndTrim(designerInfo.getIntroduction())) ? View.GONE:View.VISIBLE);
        mItemBinding.tvIntroduction.setText(designerInfo.getIntroduction());
        mItemBinding.tvRealName.setText(TextUtils.isEmpty(designerInfo.getOfficialCertificationInfo()) ? "" : convertView.getContext().getString(R.string.real_name_prefix, designerInfo.getRealname()));
        mItemBinding.tvRealName.setVisibility(!TextUtils.isEmpty(designerInfo.getOfficialCertificationInfo()) ? View.VISIBLE : View.GONE);
        mItemBinding.ivIsDesigner.setVisibility(designerInfo.getIsDesigner() ? View.VISIBLE : View.GONE);
    }
}
